package com.rayo.accesscontrollercopy.model.db.bean;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.litesuits.orm.db.annotation.Column;
import com.litesuits.orm.db.annotation.Table;
import com.rayo.accesscontrollercopy.config.NetworkConfig;

import java.util.Date;
import java.util.List;

/**
 * Created by yanghaojie on 16/7/27.
 */
@Table("calendar_table")
public class CalendarData extends BaseModel {
    public static final String CALENDAR_ID = "calid";
    public static final String CALENDAR = "cal";

    @Column(CALENDAR_ID)
    private int calid;

    @JSONField(format = NetworkConfig.JSON_DATE)
    @Column(CALENDAR)
    private Date calendar;

    private int type;

    public CalendarData() {
        this.calid = 0;
        this.calendar = new Date();
        this.type = 0;
        this.editime = new Date();
    }

    public CalendarData(int calid, Date cal, int type) {
        this.calid = calid;
        this.calendar = cal;
        this.type = type;
        this.editime = new Date();
    }

    public int getCalid() {
        return calid;
    }

    public void setCalid(int calid) {
        this.calid = calid;
    }

    public Date getCalendar() {
        return calendar;
    }

    public void setCalendar(Date calendar) {
        this.calendar = calendar;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public static List<CalendarData> formJsonStr(String data) {
        List<CalendarData> list;
        try {
            list = JSON.parseArray(data, CalendarData.class);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
        return list;
    }
}
